package com.kaifamiao.sequence;

import java.util.Arrays;

public final class CharacterStrings implements CharSequence {
	
	private final char[] value ;
	
	public CharacterStrings(char[] value) {
		super();
		this.value = Arrays.copyOf( value , value.length );
	}

	@Override
	public int length() {
		return value.length ;
	}

	@Override
	public char charAt(int index) {
		return value[index];
	}

	@Override
	public CharSequence subSequence(int start, int end) {
		char[] array = Arrays.copyOfRange( value , start, end );
		CharacterStrings cs = new CharacterStrings( array );
		return cs;
	}

	@Override
	public String toString() {
		return String.valueOf(value);
	}

}
